package com.offer.leetcode;

/**
 * leetcode-剑指offer Solution58
 */
public class Solution15 {

    public int hammingWeight(long n) {

        int count = 0;

        while(n != 0) {
            if ( (n&1) == 1) {
                ++count;
            }

            n = n >>> 1;
        }

        return count;
        
    }

    public static void main(String[] args) {
        Solution15 s = new Solution15();
        // System.out.println(s.reverseLeftWords("lrloseumgh", 6));
        System.out.println(s.hammingWeight(-1));


    }

}